"""4.1 【资源类】Resource 服务端开发"""
from mcp.server.fastmcp import FastMCP

#创建MCP实例
mcp = FastMCP("Resource MCP Server")

#创建浆糊
@mcp.resource(
    uri="file:///query/book.txt",
    name="book",
    description="查询书籍信息",
    mime_type="text/plain",
)
def query_book():
    """
     读取本地文件books.txt
     """
    with open("books.txt", "r",encoding="utf-8") as f:
        content = f.read()
        return content

if __name__ == "__main__":
    print("Resource MCP Server is running...")
    mcp.run(transport="stdio")